package com.sfx.concurrent.demo.concurrent.interrupt;

import lombok.extern.slf4j.Slf4j;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-06-28
 * Time: 10:44
 */
@Slf4j(topic = "c.InterruptTest3")
public class InterruptTest3 {
    /**
     * 打断线程
     * @param args
     */
    public static void main(String[] args) throws InterruptedException {
        //1.打断阻塞的线程
        Thread t1 = new Thread(() -> {
            log.debug("sleep...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "t1");
        t1.start();
        Thread.sleep(600);
        t1.interrupt();
        log.debug(t1.isInterrupted()+"");
    }
}